package com.lijz;

import com.lijz.annotation.UserAccess;
import com.lijz.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 1.切面 --->ok
 * 2.注解---->ok
 * 3.枚举----> 用枚举定义单例
 * 4.多数据源----> mybatisplus 有问题  需要引入他们定义的新的包  问题出在MybatisPlusAutoConfiguration中
 * 5.读写分离
 * 6.组件化
 * 7.多线程（线程间通信）
 * 8.并发编程
 * 9.java8 流  表达式
 * 10.new io
 * 11.认证
 * 12.加密解密
 * 13.shiro
 * 14.动态代理
 * 15.中间件
 * 16.设计模式
 * 17.jvm原理
 */
@SpringBootApplication
@RestController
@ComponentScan(basePackages = "com.lijz")
public class DemoTestApplication {

	@Autowired
	private RedisUtil redisUtil;

	public static void main(String[] args) {
		SpringApplication.run(DemoTestApplication.class, args);
	}

	@RequestMapping("/test")
	@UserAccess
	public String test() {
		boolean testkey = redisUtil.hasKey("testkey1");
		if (testkey) {
			Object testkey1 = redisUtil.get("testkey1");
			System.err.println("key:" + testkey1);
			return testkey1.toString();
		} else {
			redisUtil.set("testkey1", "value1");
			return "value";
		}
	}

	@RequestMapping("/test1")
	@UserAccess
	public String test1(int i) {
		return "success:" + i;
	}
}
